<template>
	<view class="container">
		<view class="register-form">
			<view class="title">
				注册
			</view>
			<input type="text" placeholder="手机号码" v-model="phone" class="input-field" />
			<input type="email" placeholder="邮箱" v-model="email" class="input-field" />
			<input type="text" placeholder="账号" v-model="username" class="input-field" />
			<input type="password" placeholder="密码" v-model="password" class="input-field" />
			<button @click="register" class="submit-button">注册</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				email: '',
				password: '',
				phone: ''
			};
		},
		methods: {
			async register() {
				// 调用注册逻辑
				uniCloud.callFunction({
					name: "addUser",
					data: {
						username: this.username,
						password: this.password,
						email: this.email,
						phone: this.phone
					},
					success: (e) => {
						console.log("上传成功！", e.result);
						uni.showToast({
							title: "注册成功",
							duration: 2000
						});
						setTimeout(() => {
							uni.navigateTo({
								url: "../login/login?username=" + this.username
							});
						}, 1000);
					}
				})
			}

		}
	};
</script>

<style>
	.title {
		color: #000;
		text-align: center;
		line-height: 100rpx;
		font-size: 40rpx;
	}

	.container {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100vh;
	}



	.register-form {
		width: 600rpx;
		padding: 40rpx;
		border-radius: 10rpx;
		padding-bottom: 500rpx;
	}

	.input-field {
		width: 100%;
		padding: 20rpx;
		margin-bottom: 30rpx;
		border: 2rpx solid #ddd;
		border-radius: 8rpx;
	}

	.submit-button {
		width: 100%;
		padding: 20rpx;
		background-color: #F5433F;
		color: white;
		border: none;
		border-radius: 8rpx;
		cursor: pointer;
	}
</style>